package search;

import mysql.JdbcUtil;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

public class SearchOfDate implements Search {
    SearchMQL searchMQL=new SearchMQL();
    String sql;

    public SearchOfDate(){}

    /***
     *
     * @return 返回最新菜谱集
     * @throws SQLException 抛出异常
     */
    @Override
    public List<Recipe> searchAll() throws SQLException {
        sql = "select * from recipes ORDER BY update_date ASC";
        return searchMQL.mysqlSearch(sql);
    }

    /***
     *
     * @param date 时间
     * @return 返回菜谱集
     * @throws SQLException
     */
    @Override
    public List<Recipe> recipes(String date) throws SQLException {
        sql = "select * from recipes update_date <"+date+" ORDER BY update_date DESC";
        return searchMQL.mysqlSearch(sql);
    }

    public List<Recipe> recipes(String date,boolean Up) throws SQLException {
        sql = "select * from recipes update_date >="+date+" ORDER BY update_date DESC";
        return searchMQL.mysqlSearch(sql);
    }

}
